<template>
  <div class="row justify-content-center">
    <div class="col-8">
      <form name="editForm" role="form" novalidate v-on:submit.prevent="save()">
        <h2
          id="jhipsterserverApp.userShare.home.createOrEditLabel"
          data-cy="UserShareCreateUpdateHeading"
          v-text="$t('jhipsterserverApp.userShare.home.createOrEditLabel')"
        >
          Create or edit a UserShare
        </h2>
        <div>
          <div class="form-group" v-if="userShare.id">
            <label for="id" v-text="$t('global.field.id')">ID</label>
            <input type="text" class="form-control" id="id" name="id" v-model="userShare.id" readonly />
          </div>
          <div class="form-group">
            <label class="form-control-label" v-text="$t('jhipsterserverApp.userShare.shareTime')" for="user-share-shareTime"
              >Share Time</label
            >
            <div class="d-flex">
              <input
                id="user-share-shareTime"
                data-cy="shareTime"
                type="datetime-local"
                class="form-control"
                name="shareTime"
                :class="{ valid: !$v.userShare.shareTime.$invalid, invalid: $v.userShare.shareTime.$invalid }"
                :value="convertDateTimeFromServer($v.userShare.shareTime.$model)"
                @change="updateZonedDateTimeField('shareTime', $event)"
              />
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" v-text="$t('jhipsterserverApp.userShare.account')" for="user-share-account">Account</label>
            <select class="form-control" id="user-share-account" data-cy="account" name="account" v-model="userShare.account">
              <option v-bind:value="null"></option>
              <option
                v-bind:value="userShare.account && userAccountOption.id === userShare.account.id ? userShare.account : userAccountOption"
                v-for="userAccountOption in userAccounts"
                :key="userAccountOption.id"
              >
                {{ userAccountOption.id }}
              </option>
            </select>
          </div>
          <div class="form-group">
            <label class="form-control-label" v-text="$t('jhipsterserverApp.userShare.content')" for="user-share-content">Content</label>
            <select class="form-control" id="user-share-content" data-cy="content" name="content" v-model="userShare.content">
              <option v-bind:value="null"></option>
              <option
                v-bind:value="userShare.content && contentInfoOption.id === userShare.content.id ? userShare.content : contentInfoOption"
                v-for="contentInfoOption in contentInfos"
                :key="contentInfoOption.id"
              >
                {{ contentInfoOption.id }}
              </option>
            </select>
          </div>
        </div>
        <div>
          <button type="button" id="cancel-save" class="btn btn-secondary" v-on:click="previousState()">
            <font-awesome-icon icon="ban"></font-awesome-icon>&nbsp;<span v-text="$t('entity.action.cancel')">Cancel</span>
          </button>
          <button
            type="submit"
            id="save-entity"
            data-cy="entityCreateSaveButton"
            :disabled="$v.userShare.$invalid || isSaving"
            class="btn btn-primary"
          >
            <font-awesome-icon icon="save"></font-awesome-icon>&nbsp;<span v-text="$t('entity.action.save')">Save</span>
          </button>
        </div>
      </form>
    </div>
  </div>
</template>
<script lang="ts" src="./user-share-update.component.ts"></script>
